﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace Sern.Abstracts.Common
{
    [Serializable]
    public class ClientInitializationArgument : Dictionary<string, string>
    {
        public ClientInitializationArgument(){}

        protected ClientInitializationArgument(SerializationInfo serializationInfo,  StreamingContext context)
            : base(serializationInfo, context)
        {
            
        }

        public string MapReduceHostUri
        {
            get
            {
                return this["MapReduceHostUri"]; 
            }
            set
            {
                if (ContainsKey("MapReduceHostUri"))
                    this["MapReduceHostUri"] = value;
                else
                    Add("MapReduceHostUri", value);
            }
        }

        [Obsolete("Will resolve via binding factory.")]
        public string TrackerUri
        {
            get
            {
                return this["TrackerUri"];
            }
            set
            {
                if (ContainsKey("TrackerUri"))
                    this["TrackerUri"] = value;
                else Add("TrackerUri", value);
            }
        }

        public Guid ClientId
        {
            get
            {
                return new Guid(this["ClientId"]);
            }
            set
            {
                if (ContainsKey("ClientId"))
                    this["ClientId"] = value.ToString();
                else
                    Add("ClientId", value.ToString());
            }
        }

        public string HostName
        {
            get
            {
                return this["HostName"];
            }
            set
            {
                if (ContainsKey("HostName"))
                    this["HostName"] = value;
                else
                    Add("HostName", value);
            }
        }

        public Guid JobId
        {
            get
            {
                return new Guid(this["JobId"]);
            }
            set
            {
                if (ContainsKey("JobId"))
                    this["JobId"] = value.ToString();
                else
                    Add("JobId", value.ToString());
            }
        }

        public LogLevel LogLevel
        {
            get
            {
                return (LogLevel)Enum.Parse(typeof(LogLevel), this["LogLevel"]);
            }
            set
            {
                if (ContainsKey("LogLevel"))
                    this["LogLevel"] = value.ToString();
                else
                    Add("LogLevel",value.ToString());
            }
        }

        //public string KeyShape
        //{
        //    get
        //    {
        //        return this["KeyShape"];
        //    }
        //    set
        //    {
        //        if (ContainsKey("KeyShape"))
        //            this["KeyShape"] = value;
        //        else
        //            Add("KeyShape", value);
        //    }
        //}

        //public string ValueShape
        //{
        //    get
        //    {
        //        return this["ValueShape"];
        //    }
        //    set
        //    {
        //        if (ContainsKey("ValueShape"))
        //            this["ValueShape"] = value;
        //        else
        //            Add("ValueShape", value);
        //    }
        //}


    }
}
